package com.niji.littly_donkey_android.adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.StrictMode;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.makeramen.roundedimageview.RoundedImageView;
import com.niji.littly_donkey_android.R;
import com.niji.littly_donkey_android.bean.Follow;
import com.niji.littly_donkey_android.util.BitMapUtil;
import com.niji.littly_donkey_android.util.CirclePhotoUtil;
import com.niji.littly_donkey_android.util.NetworkGlideImageLoader;
import com.niji.littly_donkey_android.view.CircleImageView;

import java.util.ArrayList;

public class FollowAdapter extends ArrayAdapter<Follow> {


    private static final String TAG = "FollowAdapter";

    private Context context;

    public FollowAdapter(Context context, ArrayList<Follow> members)
    {
        super(context,0, members);
        this.context = context;
    }
    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Follow follow = getItem(position);

        if(convertView == null)
        {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_follow, parent, false);
        }

        CircleImageView roundedImageView = convertView.findViewById(R.id.follow_head);
        TextView followName = convertView.findViewById(R.id.follow_name);
        TextView followMessage = convertView.findViewById(R.id.follow_message);
        TextView followId = convertView.findViewById(R.id.follow_id);
        Button followBtn = convertView.findViewById(R.id.follow_btn);
        //thumb.setImageBitmap(BitMap.getInstance().returnBitMap(u.getThumb()));
        //android4.0后要访问网络资源需要单开线程，加入这段就不会报错了
        NetworkGlideImageLoader.getInstance().displayImage((Activity) context,follow.getHead(),roundedImageView,0,0);
        followName.setText(follow.getName());
        followId.setText("" + follow.getId());
        followMessage.setText(follow.getMessage());
        followBtn.setText(follow.getBtn());
        return convertView;
    }

}



